/*
@author: stanfor
@date: 2022/8/22 17:06
@Version: 1.0
@last modify time : 2022/8/22 17:06
*/

import React, { FC, ReactElement } from 'react';
import { Checkbox, Col, Form, CheckboxProps } from 'antd';
import { getRulesConfig, commonInterface } from '@C/base/SFields/constant';
import './index.less';

const Index: FC<Partial<commonInterface> & Omit<CheckboxProps, 'type'>> = (props): ReactElement => {
  const { name, label = 'Checkbox', span = 8, required = false, ruleIcon, formItemConfig, ...checkboxProps } = props;

  return (
    <Col span={span}>
      <div className="base-component-super-fields-common">
        <Form.Item
          name={name}
          valuePropName="checked"
          rules={getRulesConfig(required, label, ruleIcon, `请选择${label}`)}
          {...formItemConfig}
        >
          <Checkbox {...checkboxProps}>{ label }</Checkbox>
        </Form.Item>
      </div>
    </Col>
  );
};

export default Index;
